﻿@using Fzrain.Core.Domain.Lol
@{
    ViewBag.Title = "Index";
    Layout = "LolBasePage.cshtml";
}
<style>
    .mainright {
        background-color: #373434;
        color: white;
        overflow: auto;
    }

    .dataDiv {
        width: 250px;
        float: left;
    }
</style>
@(Html.Kendo().Window()
        .Name("window2").Visible(false)
          .Title("战斗详情")
    .Draggable()
    .Modal(true)
    .Width(700).Height(470)
    .Actions(actions => actions.Minimize().Maximize().Close()).Position(a => a.Left(335).Top(100))
)
<div class="mainright">
    <div>

        @Html.Kendo().Button().Content("获取数据").Name("btnDataInfo").Events(e => e.Click("DataInfo"))
		@Html.Kendo().Button().Content("获取数据").Name("btnTagInfo").Events(e => e.Click("TagInfo"))
        @{
            var dataInfo = new List<DropDownListItem>
            {
                new DropDownListItem {Text = "贡献值", Value = "2"},
                new DropDownListItem {Text = "贡献排名", Value = "3"},
                new DropDownListItem {Text = "输出伤害", Value = "1"},
                new DropDownListItem {Text = "场均击杀", Value = "4"},
                new DropDownListItem {Text = "场均死亡", Value = "5"},
                new DropDownListItem {Text = "场均助攻", Value = "6"},
                new DropDownListItem {Text = "承受伤害", Value = "7"},
            };
            var tagInfo = new List<DropDownListItem>
            {
                new DropDownListItem {Text = "三杀榜", Value = "5"},
                new DropDownListItem {Text = "四杀榜", Value = "6"},
                new DropDownListItem {Text = "五杀榜", Value = "7"},
                new DropDownListItem {Text = "超神榜", Value = "8"},
                
            };
        }
        @Html.Kendo().DropDownList().BindTo(dataInfo).Name("dataInfo")
        @Html.Kendo().DropDownList().BindTo(tagInfo).Name("tagInfo")
        @Html.Kendo().DatePicker().Name("startTime").Value("2014-10-19")
        @Html.Kendo().CheckBox().Name("isAsc").Label("是否升序")
        @Html.Kendo().CheckBox().Name("isMine").Label("我的数据")
    </div>
    <div class='dataDiv'>
    </div>
    <div id="divDetail" style="float:left;width:800px;height:850px;overflow:auto">
        @(Html.Kendo().Grid<Record>().Name("grid")
        .Columns(columns =>
        {
            columns.Bound(r => r.Battle.StartTime).Width(80).Format("{0:yyyy-MM-dd HH:mm:ss}");
            columns.Bound(r => r.IsWin).Width(60).ClientTemplate("#=IsWin==1?'<font color=\"green\">胜利</font>':'<font color=\"red\">失败</font>'#");
            columns.Bound(r => r.Name).Width(80);
            columns.Bound(r => r.Contribute).Width(60);
            columns.Command(c => c.Custom("战斗详情").Click("showDetails")).Width(80);
        })
        )


    </div>
</div>

<script type="text/javascript">
  
	function DataInfo() {
		$.post("DataInfo", { dataInfo: $("#dataInfo").val(), isAsc: $("#isAsc").prop("checked"), isMine: $("#isMine").prop("checked"), startTime: $("#startTime").val() }, function (data) {
            var html = "";
            for (var i = 0; i < data.length; i++) {
                html += "<div>" +
                    "<div style='float:left'><img width='50' src='../../Content/lolpng/" + data[i].Key + ".png' alt='' /></div>" +
                    "<div style='float:left;height:50px;line-height:50px;width:50px;text-align:center'>" + data[i].Value.toFixed(2) + "</div>" +
                    "<div style='height:50px;padding:8px 0'><a url='" + data[i].Key + "'>战绩预览</a></div>" +
                    "</div>";

            }
            $(".dataDiv").html(html);
            regeditBtn();
        });

    }
	function TagInfo() {
		$.post("TagInfo", { tagInfo: $("#tagInfo").val(), isAsc: $("#isAsc").prop("checked"), isMine: $("#isMine").prop("checked"), startTime: $("#startTime").val() }, function (data) {
			var html = "";
			for (var i = 0; i < data.length; i++) {
				html += "<div>" +
                    "<div style='float:left'><img width='50' src='../../Content/lolpng/" + data[i].Key + ".png' alt='' /></div>" +
                    "<div style='float:left;height:50px;line-height:50px;width:50px;text-align:center'>" + data[i].Value.toFixed(2) + "</div>" +
                    "<div style='height:50px;padding:8px 0'><a url='" + data[i].Key + "'>战绩预览</a></div>" +
                    "</div>";

			}
			$(".dataDiv").html(html);
			regeditBtn();
		});

	}
    function regeditBtn() {
        $("a[url]").click(function () {
            $.ajax({
                url: "BrightInfo",
                data: { championId: $(this).attr("url"), isMine: $("#isMine").prop("checked") },
                traditional: true,
                method: "post",
                success: function (result) {
                    var dataSource = new kendo.data.DataSource({ data: result });
                    var grid = $('#grid').data("kendoGrid");
                    dataSource.read();
                    grid.setDataSource(dataSource);
                    $('#grid').data('kendoGrid').refresh();
                }
            });
          
        });
    }
    function showDetails(e) {
        e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var kendoWindow = $("#window2").data("kendoWindow");
        $.post("/Lol/GetBattleDetail", { GameId: dataItem.Battle.GameId }, function (data) {
            kendoWindow.content(data);
            kendoWindow.center().open();
        });


    }
</script>
